<template>
  <question-card-list :question-list="questionList"/>
  <van-empty v-if="!questionList || questionList.length<1" description="搜索结果为空"/>
</template>

<script setup>
import {useRoute} from "vue-router";
import QuestionCardList from "../components/QuestionCardList.vue";
import {onMounted, ref} from "vue";
import myAxios from "../request/myAxios";
import {Toast} from "vant";

const route = useRoute()
const questionType = route.query.questionType;
const belongToUnit = route.query.questionUnit;
const questionList = ref([]);
console.log(questionType);
console.log(belongToUnit);
onMounted(async ()=>{
  questionList.value = await myAxios.get('/question/list',{
    params:{
      questionType,
      belongToUnit
    },
  }).then(res =>{
    console.log('/question/list success',res);
    return res.data?.data;
  }).catch((error)=>{
    console.error('/question/list fail',error);
    Toast.fail('请求失败');
  })
});
</script>

<style scoped>

</style>
